package com.nbsaas.boot.data.rest.convert;

import com.nbsaas.boot.data.data.entity.QueryTemplate;
import com.nbsaas.boot.data.api.domain.simple.QueryTemplateSimple;

import com.nbsaas.boot.rest.api.Converter;
import java.util.HashMap;
import java.util.Map;

/**
* -列表对象转换器
*/

public class QueryTemplateSimpleConvert implements Converter<QueryTemplateSimple, QueryTemplate> {




@Override
public QueryTemplateSimple convert(QueryTemplate source) {
    QueryTemplateSimple result = new QueryTemplateSimple();

                if(source.getJumpType()!=null){
                   Map<Integer,String> JumpTypeMap=new HashMap<>();
                       JumpTypeMap.put(1,"行跳转");
                       JumpTypeMap.put(2,"列跳转");
                       JumpTypeMap.put(3,"不跳转");
                   String label=  JumpTypeMap.get(source.getJumpType());
                   result.setJumpTypeName(label);
                }
                result.setJumpType(source.getJumpType());
                if(source.getDataScope6()!=null){
                   Map<Integer,String> DataScope6Map=new HashMap<>();
                       DataScope6Map.put(1,"部分数据");
                       DataScope6Map.put(2,"全部数据");
                   String label=  DataScope6Map.get(source.getDataScope6());
                   result.setDataScope6Name(label);
                }
                result.setDataScope6(source.getDataScope6());
                result.setNote(source.getNote());
                if(source.getPreType()!=null){
                   Map<Integer,String> PreTypeMap=new HashMap<>();
                       PreTypeMap.put(1,"进行预处理");
                       PreTypeMap.put(2,"不预处理");
                   String label=  PreTypeMap.get(source.getPreType());
                   result.setPreTypeName(label);
                }
                result.setPreType(source.getPreType());
                if(source.getDataScope2()!=null){
                   Map<Integer,String> DataScope2Map=new HashMap<>();
                       DataScope2Map.put(1,"部分数据");
                       DataScope2Map.put(2,"全部数据");
                   String label=  DataScope2Map.get(source.getDataScope2());
                   result.setDataScope2Name(label);
                }
                result.setDataScope2(source.getDataScope2());

                try {
                    if(source.getQueryCatalog()!=null){
                        result.setQueryCatalogName(source.getQueryCatalog().getName());
                    }
                } catch (Exception ignored) { }

                result.setDateRange(source.getDateRange());
                if(source.getDataScope3()!=null){
                   Map<Integer,String> DataScope3Map=new HashMap<>();
                       DataScope3Map.put(1,"部分数据");
                       DataScope3Map.put(2,"全部数据");
                   String label=  DataScope3Map.get(source.getDataScope3());
                   result.setDataScope3Name(label);
                }
                result.setDataScope3(source.getDataScope3());
                if(source.getDataScope4()!=null){
                   Map<Integer,String> DataScope4Map=new HashMap<>();
                       DataScope4Map.put(1,"部分数据");
                       DataScope4Map.put(2,"全部数据");
                   String label=  DataScope4Map.get(source.getDataScope4());
                   result.setDataScope4Name(label);
                }
                result.setDataScope4(source.getDataScope4());

               try {
                   if(source.getModifier()!=null){
                       result.setModifier(source.getModifier().getId());
                   }
                } catch (Exception ignored) { }

                if(source.getDataScope5()!=null){
                   Map<Integer,String> DataScope5Map=new HashMap<>();
                       DataScope5Map.put(1,"部分数据");
                       DataScope5Map.put(2,"全部数据");
                   String label=  DataScope5Map.get(source.getDataScope5());
                   result.setDataScope5Name(label);
                }
                result.setDataScope5(source.getDataScope5());

                try {
                    if(source.getCreator()!=null){
                        result.setCreatorName(source.getCreator().getName());
                    }
                } catch (Exception ignored) { }

                result.setClassName(source.getClassName());
                result.setSlowQuery(source.getSlowQuery());
                if(source.getDataScope1()!=null){
                   Map<Integer,String> DataScope1Map=new HashMap<>();
                       DataScope1Map.put(1,"部分数据");
                       DataScope1Map.put(2,"全部数据");
                   String label=  DataScope1Map.get(source.getDataScope1());
                   result.setDataScope1Name(label);
                }
                result.setDataScope1(source.getDataScope1());
                if(source.getType()!=null){
                   Map<Integer,String> TypeMap=new HashMap<>();
                       TypeMap.put(1,"公共查询");
                       TypeMap.put(2,"私有查询");
                   String label=  TypeMap.get(source.getType());
                   result.setTypeName(label);
                }
                result.setType(source.getType());
                result.setJumpUrl(source.getJumpUrl());
                result.setHeaderStyle(source.getHeaderStyle());

               try {
                   if(source.getQueryCatalog()!=null){
                       result.setQueryCatalog(source.getQueryCatalog().getId());
                   }
                } catch (Exception ignored) { }

                result.setResultHandleType(source.getResultHandleType());
                result.setId(source.getId());
                result.setSummaryModel(source.getSummaryModel());
                result.setLastDate(source.getLastDate());
                result.setDateLimitField(source.getDateLimitField());

               try {
                   if(source.getCreator()!=null){
                       result.setCreator(source.getCreator().getId());
                   }
                } catch (Exception ignored) { }

                if(source.getSummaryType()!=null){
                   Map<Integer,String> SummaryTypeMap=new HashMap<>();
                       SummaryTypeMap.put(1,"汇总");
                       SummaryTypeMap.put(2,"不汇总");
                   String label=  SummaryTypeMap.get(source.getSummaryType());
                   result.setSummaryTypeName(label);
                }
                result.setSummaryType(source.getSummaryType());
                if(source.getBeforeHandle()!=null){
                   Map<Integer,String> BeforeHandleMap=new HashMap<>();
                       BeforeHandleMap.put(1,"进行后处理");
                       BeforeHandleMap.put(2,"不后处理");
                   String label=  BeforeHandleMap.get(source.getBeforeHandle());
                   result.setBeforeHandleName(label);
                }
                result.setBeforeHandle(source.getBeforeHandle());
                result.setPermission(source.getPermission());
                result.setAddDate(source.getAddDate());
                if(source.getQueryType()!=null){
                   Map<Integer,String> QueryTypeMap=new HashMap<>();
                       QueryTypeMap.put(1,"查询");
                       QueryTypeMap.put(2,"报表");
                       QueryTypeMap.put(101,"批量查询");
                       QueryTypeMap.put(4,"待办");
                   String label=  QueryTypeMap.get(source.getQueryType());
                   result.setQueryTypeName(label);
                }
                result.setQueryType(source.getQueryType());
                result.setStoreProcedure(source.getStoreProcedure());
                if(source.getDateLimit()!=null){
                   Map<Integer,String> DateLimitMap=new HashMap<>();
                       DateLimitMap.put(1,"限制");
                       DateLimitMap.put(2,"不限制");
                   String label=  DateLimitMap.get(source.getDateLimit());
                   result.setDateLimitName(label);
                }
                result.setDateLimit(source.getDateLimit());
                result.setName(source.getName());

                try {
                    if(source.getModifier()!=null){
                        result.setModifierName(source.getModifier().getName());
                    }
                } catch (Exception ignored) { }

                result.setCacheModel(source.getCacheModel());
                if(source.getDebugMode()!=null){
                   Map<Integer,String> DebugModeMap=new HashMap<>();
                       DebugModeMap.put(1,"调试模式");
                       DebugModeMap.put(2,"运行模式");
                   String label=  DebugModeMap.get(source.getDebugMode());
                   result.setDebugModeName(label);
                }
                result.setDebugMode(source.getDebugMode());
                result.setPreSql(source.getPreSql());


    return result;
}

}